<?php
	$CI =& get_instance();

	$pid = $this->model_nav->get_parent_level($node['id']);
	$tree = $this->model_nav->fetchNav($pid);
	$rows = $this->model_c1->find_by_nodeid($node['id']);

	$p_node_cur = $this->model_nav->get_parent($node['id']);
	$p_node = $this->model_nav->find($p_node_cur);
	$list_node = $this->model_nav->fetchNav($p_node_cur);
	$t1 = unserialize($content['t1']);
	$list_media = null;
	if(isset($t1['set_ids'])){
		$CI->load->model("Model_mediaset", "model_mediaset");
		$CI->load->model("Model_media", "model_media");
		$sets = $CI->model_mediaset->find_by_ids($t1['set_ids']);
		$ids = null;
		foreach($sets as $item){
			$ids .= $item['media_ids'] . ",";
		}
		$ids = explode(",",$ids);
		$list_media = $CI->model_media->find_by_ids($ids);
	}
	$media_thumb = $CI->config->item("media_thumb");
?>
<div class="left-2-col texture">
	<ul class="bullet_list">
		<?php foreach($tree as $item):
				$class = "";
				if($p_node_cur == $item['id'])
					$class = "selected";
		?>
		<li class="<?=$class?>">
			<a href="<?=site_url(array('c' => 'home','m' => 'index', 'nav'=>$item['id']))?>" title="<?=htmlspecialchars($item['nav_name'])?>"><?=htmlspecialchars($item['nav_name'])?></a>
		</li>
		<?php endforeach; ?>
	</ul>
</div>
<div class="col_center" id="page_search">
	<div class="left h2"><?= htmlspecialchars($p_node['nav_name']) ?> ></div>
	<div class="left text_left p_realtive">
		<span class="company_list" id="company_list"><?= $node['nav_name'] ?></span>
		<ul class="companies_list">
		<?php 	$count_child = count($list_node);
				$i=0;
				foreach($list_node as $item):
					$class_child = "";
					if($i == ($count_child-1))
						$class_child = "last";
		?>
					<li class="<?=$class_child?>"><a href="<?=site_url(array('c' => 'home','m' => 'index', 'nav'=>$item['id']))?>" title="<?=htmlspecialchars($item['nav_name'])?>"><?=htmlspecialchars($item['nav_name'])?></a></li>
		<?php 	$i++;
				endforeach; ?>
		</ul>
	</div>
	<div class="clearfix"></div>
	<div class="text_content">
		<?=@$t1['content']?>
	</div>
	<div class="gallery-cont">
		<h4><b><?=$this->lang->line('Gallery');?></b></h4>
		<?php if(!empty($list_media)):?>
		<?php
			$count_list = count($list_media);
			$height = "min-height:110px;";
		    if($count_list >= 5) $height = "min-height:210px;";
		    if($count_list >= 10) $height = "min-height:305px;";
		    $class = "disabled";
		    if($count_list>15) $class = "";
     	?>
		<div class="navi"></div>
		<div class="scrollable" style="<?=$height?>">
			<div class="gallery-grid">
				<?php $k = 0; foreach($list_media as $item):?>
				<?php if($k==0 || ($k % 15 == 0)):?>
				<div class="media-group">
				<?php endif;?>
					<div class="item">
						<a class="customGal" href="<?=$media_thumb['user_media_url'].$item['rawname'].$item["fileext"]?>" title="<?=$item['content']?>" style="width: 120px">
							<img src="<?=$media_thumb['user_media_url'].$item['rawname'].$media_thumb['thumb_marker'].$item["fileext"]?>" alt="<?=$item['title']?>" width="120px"/>
							<span class="gallery-bg"></span>
							<span class="gallery-border"></span>
						</a>
					</div>
					<?php if(($k > 1) && ($k % 5 == 4)):?>
					<div class="clearfix"></div>
					<?php endif;?>
				<?php if((($k != 0) && ($k % 15 == 14)) || ($k+1==count($list_media))):?>
				</div>
				<?php endif;?>
				<?php $k++;endforeach; ?>
			</div>
			<div class="clearfix"></div>
		</div>
		<div style="margin: 0 300px;">
			<a class="prevPage browse left"></a>
			<a class="nextPage browse right <?=$class?>"></a>
		</div>
		<?php endif;?>
	</div>
</div>
<div class="clearfix"></div>
<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
	$("#company_list").hover(function(){
		$(".companies_list").show();
	});

	$(".companies_list").hover(function(){},
		function(){setTimeout(function(){$(".companies_list").hide('slow')},1000);
	});
	// cal width and height span border
	$(".customGal").each(function(){
		$(this).find(".gallery-bg").width($(this).width()).height($(this).height());
		$(this).find(".gallery-border").width($(this).width()-16).height($(this).height()-16);
		//.width($(this).width())).height($(this).height());
	});
	$(".scrollable").height($(".media-group").height()).scrollable({size:1, items: ".gallery-grid"}).navigator();
	// Zoom image
	$('a.customGal').zoomimage({
		border: 20,
		centered: true,
		hideSource: true
	});
});
</script>